package com.bestcem.xm.ticket.grpc.client.enums;

import lombok.Getter;
import lombok.ToString;

/**
 * om答题终端类型
 *
 * @author zhangfeng <feng.zhang@idiaoyan.com>
 * @version v1.0
 * @date 2021/7/15 16:07
 */
@Getter
@ToString
public enum RespondentClientTypeEnum {
    /**
     * PC
     */
    PC("PC", 0),
    /**
     * 平板
     */
    PAD("平板", 1),
    /**
     * 手机
     */
    PHONE("手机", 2),
    /**
     * 未知
     */
    UNKNOWN("未知", 3);

    private final String name;

    private final Integer index;

    RespondentClientTypeEnum(String name, Integer index) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则返回 null
     *
     * @param index 枚举index
     * @author zq.ding <zq.ding@idiaoyan.com>
     * @date 2021/8/31 13:35
     */
    public static RespondentClientTypeEnum getByIndex(Integer index) {
        for (RespondentClientTypeEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return null;
    }
}
